/*
 * @Author: duanguang
 * @Date: 2019-11-07 09:31:57
 * @LastEditTime: 2021-10-27 22:34:34
 * @LastEditors: duanguang
 * @Description: 
 * @FilePath: /legions-server/app/abstract/controller/common.ts
 * 「扫去窗上的尘埃，才可以看到窗外的美景。」
 */
import { Controller } from 'egg';
import ResponseModel from '../../model/responseModel';
import { UserInfoEntity } from '../../model/user';

export default class CommonController extends Controller {
    success<T = {}>(data: ResponseModel<T>|undefined) {
        this.ctx.body = data;
    }
    /** 获取用户信息，路由需要加中间件jwt */
    get userInfo(): UserInfoEntity | null {
        return this.ctx.state.user ? this.ctx.state.user.userInfo : null;
    }
}
